package com.thread.learn.thread2;

public class Demo1 extends Thread{
	
	public Demo1(String name) {
		super(name);
	}

	@Override
	public void run() {
		while (!interrupted()) {
			System.out.println(getName()+":线程执行了...");
		}
	}
	
	public static void main(String[] args) throws InterruptedException {
		Demo1 d1=new Demo1("first-thread");
		Demo1 d2=new Demo1("second-thread");
		
//		d1.setDaemon(true);//守护线程
//		d2.setDaemon(true);//守护线程
		
		d1.start();
		d2.start();
		
		d1.interrupt();//停止线程
		
	}
	
}
